# coding: utf-8
import threading
from collections import Counter
import time
from concurrent.futures import thread
import datetime
from decimal import Decimal
from random import random

import numpy as numpy
import xlrd

from wechat.vedio.response_class import RequestsEdit
from wechat.vedio.tools import notice


def getNums():
    # str = "355.1万人看过 · 32.1万热度"
    list = str.split("人看过")
    listRes = []
    if list[0].find("万") != -1:
        listRes.insert(0, int(eval(list[0][:-1]) * 10000))
    else:
        listRes.insert(0, int(list[0]))
    if list[1] != "":
        if list[1].find("万") != -1:
            i = list[1].index("万")
            listRes.insert(1, int(eval(list[1][3:i]) * 10000))
        else:
            j = list[1].index("热")
            listRes.insert(1, int(list[1][3:j]))

    return listRes


def getZan(d):
    zanNum = 0
    zan = d.xpath('//*[@resource-id="com.tencent.mm:id/egb"]').get_text()
    if zan.find("万") != -1:
        zanNum = int(eval(zan[:-1]) * 10000)
    else:
        zanNum = int(zan)

    return zanNum


def checkShopBag(d):
    shopBagExist = False
    if d.xpath('com.tencent.mm:id/cxc').exists:
        shopBagExist = True
    return shopBagExist


def getTheme():
    themeBase = []
    value1 = "位置 广西沃柑500单正在秒杀活动中"
    value2 = "位置 南宁市 • 南宁市武鸣区双桥镇人民政府"
    themeBase.append(value1)
    themeBase.append(value2)
    str = "asdsad"
    if str not in themeBase:
        themeBase.append(str)
    else:
        print()
    return themeBase


def checkMap():
    str1 = "教材等服務\\\\n欢迎私信\\goodsWindow\\""";
    print(str1.replace("\\", ""))
    str = "有：啊1"
    value1 = "adasda"
    list = str.split("：")
    bool = list[0] == "有"
    goodsBag = {"a": 1, "b": 2, "有": "啊"}
    goodsBag1 = {}
    i = Counter(goodsBag1.values())["1"]
    if value1.find("：") != -1:
        print(111)

    if (list[0] in goodsBag.keys()) and (list[1] == goodsBag.get(list[0])):
        print(111)
    else:
        print(222)

    value = "b"

    if value not in goodsBag.keys():
        goodsBag[value] = 1
    else:
        goodsBag[value] = goodsBag.get(value) + 1
    print()
    print()


def getNameFromXls(file, sheet_index, col_index):
    time.time()
    data = xlrd.open_workbook(file)  # 打开文件
    table = data.sheets()[sheet_index]  # 指定为哪一个sheet
    colnames = table.col_values(col_index)  # 指定哪一列从0开始
    print(colnames)
    return colnames


def uploadtest():
    numStr = "粉丝团成员：809人"
    Num = numStr.split("：")[1][0:-1]


    list = []
    resList = []
    str = {"ts": 11,"v": 11}
    list.append(str)
    print(list)
    str["ts"] = 22
    str["v"] = 22
    list.append(str)
    print(list)
    str["ts"] = 33
    str["v"] = 33
    list.append(str)
    print(list)



    viewTrendList=[{"ts": int(round(time.time() * 1000)),
                       "v": 11}]
    for i in range(1,5,1):
        viewTrendList.append({"ts": int(round(time.time() * 1000*i)),
                       "v": 11})
    print(viewTrendList)
    print(int(round(time.time() * 1000)))
    s = int(round(time.time() * 1000))
    currentHour = int(datetime.datetime.now().strftime('%M'))
    print(currentHour)
    for i in range(5):
        for j in range(5):
            print(i, j)
            if i == 3 and j == 3:
                break
        else:
            continue
        break
    print()


    l = {}
    l["1"] = "1a"
    l["2"] = "2a"
    print()
    str1 = "￥39.8"
    zanNum = int(Decimal(str1[1:]) * 100)
    zanNum1 = int(eval(str[1:]) * 100)
    print(zanNum)
    lists = [{
            "videoNumberName": "name",
            "goodJob": "goodJob",
            "hot": "hot"},{
            "videoNumberName": "name",
            "goodJob": "goodJob",
            "hot": "hot"},{
            "videoNumberName": "name",
            "goodJob": "goodJob",
            "hot": ""}]
    for i in lists:
        if i["hot"] == "":
            print()

    for j in range(len(lists) -1 ,0,-1):
        if i == lists[j][0]:
            print(j)

    for i in range(1, 5, 1):
        print(i)

    devices = ['a','b','c','d','e','f','g','h']
    for i in range(0,len(devices),2):
        n = devices[i:i+2]
        m = i//2
    # for i in range(0, 2, 2):
        print(n)
        print(m)

    # str = "abcd"
    # str1 = str[0:2]
    # print(str1)
    # str = {'videoNumberName': '大表姐刘珠琰', 'startedAt': '2022-02-08 15:49:55', 'title': '清仓特价一件不留抢疯了', 'userView': 93000}
    # str['userView'] = 100
    # str1 = str
    # print(str)

    # goods_data = {
    #     "endedAt": "2020-01-22 00:01:02.0",
    #     "startedAt": "2020-01-22 00:01:03.0",
    #     "title": "testUpload",
    #     "userView": 12345,
    #     "videoNumberName": "王好"
    # }
    # goods_data = {'videoNumberName': '热河路旁的大梧桐', 'startedAt': '2022-01-27 17:37:36', 'title': 'titleTest',
    #               'userView': 0, 'endedAt': '2022-01-27 17:38:12'}
    # upload_url = "https://h5.guang.com/live/rpa/live/data.json"
    # # # data = json.dumps(goods_data)
    # res = RequestsEdit.post(post_data=goods_data, url=upload_url)
    # notice("王好","2020-01-22 00:01:02.0")
    # print()

    str = "wanghao1"
    data = {}
    liveDetailDictList = [{"name": "wanghao", "startAt": "10:11", "endedAt": "10:11"},
                          {"name": "wanghao1", "startAt": "10:11", "endedAt": "10:11"},
                          {"name": "wanghao2", "startAt": "10:11", "endedAt": "10:11"}]
    livePersonList = ["wanghao", "wanghao1", "wanghao2"]
    for i in liveDetailDictList:
        if i['name'] == str:
            data = i
            liveDetailDictList.remove(i)
    livePersonList.remove(str)
    print()

    # data = {}
    # for i in livePersonDict:
    #     if i['name'] == str:
    #         data = i
    # print(data)
    # str = "wanghao1"
    # if str in livePersonList:
    # existFlag = true
    # else:
    # existFlag = false
    # check living flag
    # if existFlag == true and living:
    #     continue
    # elif existFlag == false and living:
    #     put in dict and list
    # if existFlag == true and not not living:
    #     post to cloud
    #     remove in dict and list
    # if existFlag == false and not living:
    #     continue


if __name__ == '__main__':
    uploadtest()
